
             
/**
 * 
 *
 * @File name:  TFixedAssetsDao.java 
 * @Create on:  2011-10-31 17:00:07
 * @Author   :  陈伟
 *
 * @ChangeList
 * ---------------------------------------------------
 * Date         Editor              ChangeReasons
 *
 */
           
        package com.boho.estates.assetsbase.dao;

            
import java.sql.Connection;
import java.util.LinkedList;
import java.util.List;

import cn.boho.framework.po.CQuery;
import cn.boho.framework.po.CQueryFactoryTool;
import cn.boho.framework.po.ComboPager;
import cn.boho.framework.po.DAO;
import cn.boho.framework.po.DynaBeanMap;
import cn.boho.framework.po.Pager;
            
        /**
 * 【资产基本信息:T_FIXED_ASSETS】的Dao操作类
 * 
 */
public class TFixedAssetsDao extends DAO {
	/**
	* 查询所有【资产基本信息:T_FIXED_ASSETS】信息
	* @param con
	* @return
	* @throws Exception
	* @date 2011-10-31
	* @author 陈伟
	*
	*/
	public static List queryTFixedAssets(Connection con,String name,String fixedAssetsType)throws Exception{
		List list = new LinkedList();
		StringBuffer sql = new StringBuffer();
		sql.append("select * from T_FIXED_ASSETS where IS_VALID = 1 ");
		CQuery query = CQueryFactoryTool.createFactory().createCQuery();
		int i = 0;
		if(!"".equals(name)){
			sql.append(" and lower(FIXED_ASSETS_NAME) like ?");
			query.setString(++i, "%"+name.toLowerCase()+"%");
		}
		if(!"".equals(fixedAssetsType)){
			sql.append(" and FIXED_ASSETS_TYPE= ?");
			query.setString(++i, fixedAssetsType);
		}
		sql.append(" order by FIXED_ASSETS_NO desc");
		query.setCommand(sql.toString());
		logger.debug("TFixedAssetsDao.queryTFixedAssets() SQL->"+query.getCommand());
		list = query.getDynaBeanMapList("T_FIXED_ASSETS", con);
		return list;
	}
	/**
	* 分页查询所有【资产基本信息:T_FIXED_ASSETS】信息
	* @param con
	* @param pager
	* @return
	* @throws Exception
	* @date 2011-10-31
	* @author 陈伟
	*
	*/
	public static ComboPager queryTFixedAssetsByPager(Connection con,Pager pager, String name, String type, String brand)throws Exception{
		StringBuffer sql = new StringBuffer();
		sql.append("select * from T_FIXED_ASSETS where IS_VALID = 1 ");
		CQuery query = CQueryFactoryTool.createFactory().createCQuery();
		int i = 0;
		if(!"".equals(name)){
			sql.append(" and lower(FIXED_ASSETS_NAME) like ?");
			query.setString(++i, "%"+name.toLowerCase()+"%");
		}
		if(!"".equals(type)){
			sql.append(" and FIXED_ASSETS_TYPE = ?");
			query.setString(++i, type);
		}
		if(!"".equals(brand)){
			sql.append(" and lower(BRAND) like ?");
			query.setString(++i, "%"+brand.toLowerCase()+"%");
		}
		sql.append(" order by FIXED_ASSETS_NO desc");
		query.setCommand(sql.toString());
		return query.getDynaBeanMapComboPager("T_FIXED_ASSETS", pager,con);
	}
	/**
	* 根据主键【资产基本信息编号:FIXED_ASSETS_NO|】获得信息
	* @param con
	* @param fixedAssetsNo 资产基本信息编号
	* @return
	* @throws Exception
	* @date 2011-10-31
	* @author 陈伟
	*
	*/
	public static DynaBeanMap getTFixedAssetsByPk(Connection con,java.lang.Integer fixedAssetsNo)throws Exception{
		DynaBeanMap dynaBeanMap = null;
		StringBuffer sql = new StringBuffer();
		sql.append("select * from T_FIXED_ASSETS where  FIXED_ASSETS_NO=? and IS_VALID = 1");
		CQuery query = CQueryFactoryTool.createFactory().createCQuery();
		query.setCommand(sql.toString());
		query.setInt(1,fixedAssetsNo);
		dynaBeanMap = query.getDynaBeanMap("T_FIXED_ASSETS", con);
		return dynaBeanMap;
	}

}
